<!-- HTML header for doxygen 1.8.3.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.3.1"/>
<title>AngelScript: Strings</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="test/javascript" src="touch.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { searchBox.OnSelectItem(0); });
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="aslogo_small.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">AngelScript
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.3.1 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('doc_datatypes_strings.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
<a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Classes</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Typedefs</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Macros</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(9)"><span class="SelectionMark">&#160;</span>Pages</a></div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="headertitle">
<div class="title">Strings </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><dl class="section note"><dt>Note</dt><dd>Strings are only available in the scripts if the application <a class="el" href="doc_addon_std_string.html">registers the support for them</a>. The syntax for using strings may differ for the application you're working with so consult the application's manual for more details.</dd></dl>
<p>Strings hold an array of bytes or 16bit words depending on the application settings. Normally they are used to store text but can really store any kind of binary data.</p>
<p>There are two types of string constants supported in the AngelScript language, the normal quoted string, and the documentation strings, called heredoc strings.</p>
<p>The normal strings are written between double quotation marks (<code>"</code>) or single quotation marks (<code>'</code>). Inside the constant strings some escape sequences can be used to write exact byte values that might not be possible to write in your normal editor.</p>
<table  cellspacing="0" cellpadding="0" border="0">
<tr>
<td width="100" valign="top"><b>sequence</b> </td><td valign="top" width="100"><b>value</b> </td><td valign="top"><p class="starttd"><b>description</b></p>
<p class="endtd"></p>
</td></tr>
<tr>
<td width="80" valign="top"><code>\0</code>&#160;  </td><td valign="top" width="50">0 </td><td valign="top">null character </td></tr>
<tr>
<td width="80" valign="top"><code>\\</code>&#160;  </td><td valign="top" width="50">92 </td><td valign="top">back-slash </td></tr>
<tr>
<td width="80" valign="top"><code>\'</code>&#160;  </td><td valign="top" width="50">39 </td><td valign="top">single quotation mark (apostrophe) </td></tr>
<tr>
<td width="80" valign="top"><code>\"</code>&#160;  </td><td valign="top" width="50">34 </td><td valign="top">double quotation mark </td></tr>
<tr>
<td width="80" valign="top"><code>\n</code>&#160;  </td><td valign="top" width="50">10 </td><td valign="top">new line feed </td></tr>
<tr>
<td width="80" valign="top"><code>\r</code>&#160;  </td><td valign="top" width="50">13 </td><td valign="top">carriage return </td></tr>
<tr>
<td width="80" valign="top"><code>\t</code>&#160;  </td><td valign="top" width="50">9 </td><td valign="top">tab character </td></tr>
<tr>
<td width="80" valign="top"><code>\xFFFF</code>&#160; </td><td valign="top" width="50">0xFFFF </td><td valign="top">FFFF should be exchanged for a 1 to 4 digit hexadecimal number representing the value wanted. If the application uses 8bit strings then only values up to 255 is accepted. </td></tr>
<tr>
<td width="80" valign="top"><code>\uFFFF</code>&#160; </td><td valign="top" width="50">0xFFFF </td><td valign="top">FFFF should be exchanged for the hexadecimal number representing the unicode code point </td></tr>
<tr>
<td width="80" valign="top"><code>\UFFFFFFFF</code>&#160; </td><td valign="top" width="50">0xFFFFFFFF </td><td valign="top">FFFFFFFF should be exchanged for the hexadecimal number representing the unicode code point </td></tr>
</table>
<pre>
  string str1 = "This is a string with \"escape sequences" .";
  string str2 = 'If single quotes are used then double quotes can be included without "escape sequences".';
</pre><p>The heredoc strings are designed for inclusion of large portions of text without processing of escape sequences. A heredoc string is surrounded by triple double-quotation marks (<code>"""</code>), and can span multiple lines of code. If the characters following the start of the string until the first linebreak only contains white space, it is automatically removed by the compiler. Likewise if the characters following the last line break until the end of the string only contains white space this is also removed.</p>
<pre>
  string str = """
  This is some text without "escape sequences". This is some text.
  This is some text. This is some text. This is some text. This is
  some text. This is some text. This is some text. This is some
  text. This is some text. This is some text. This is some text.
  This is some text.
  """;
</pre><p>If more than one string constants are written in sequence with only whitespace or comments between them the compiler will concatenate them into one constant.</p>
<pre>
  string str = "First line.\n"
               "Second line.\n"
               "Third line.\n";
</pre><p>The escape sequences \u and \U will add the specified unicode code point as a UTF-8 or UTF-16 encoded sequence depending on the application settings. Only valid unicode 5.1 code points are accepted, i.e. code points between U+D800 and U+DFFF (reserved for surrogate pairs) or above U+10FFFF are not accepted.</p>
<h1><a class="anchor" id="doc_datatypes_strings_addon"></a>
Supporting string object and functions</h1>
<p>The string object supports a number of operators, and has several class methods and supporting global functions to facilitate the manipulation of strings.</p>
<h2><a class="anchor" id="doc_datatypes_strings_addon_ops"></a>
Operators</h2>
<p><b>= assignment</b><br/>
</p>
<p>The assignment operator copies the content of the right hand string into the left hand string.</p>
<p>Assignment of primitive types is allowed, which will do a default transformation of the primitive to a string.</p>
<p><b>+, += concatenation</b><br/>
</p>
<p>The concatenation operator appends the content of the right hand string to the end of the left hand string.</p>
<p>Concatenation of primitives types is allowed, which will do a default transformation of the primitive to a string.</p>
<p><b>==, != equality</b><br/>
</p>
<p>Compares the content of the two strings.</p>
<p><b>&lt;, &gt;, &lt;=, &gt;= comparison</b><br/>
</p>
<p>Compares the content of the two strings. The comparison is done on the byte values in the strings, which may not correspond to alphabetical comparisons for some languages.</p>
<p><b>[] index operator</b><br/>
</p>
<p>The index operator gives access to a single byte in the string.</p>
<h2><a class="anchor" id="doc_datatypes_strings_addon_mthd"></a>
Methods</h2>
<p><b>uint length() const</b><br/>
</p>
<p>Returns the length of the string.</p>
<p><b>void resize(uint)</b><br/>
</p>
<p>Sets the length of the string.</p>
<p><b>bool isEmpty() const</b><br/>
</p>
<p>Returns true if the string is empty, i.e. the length is zero.</p>
<p><b>string substr(uint start = 0, int count = -1) const</b><br/>
</p>
<p>Returns a string with the content starting at <em>start</em> and the number of bytes given by count. The default arguments will return the whole string as the new string.</p>
<p><b>void insert(uint pos, const string &amp;in other)</b><br/>
</p>
<p>Inserts another string <em>other</em> at position <em>pos</em> in the original string.</p>
<p><b>void erase(uint pos, int count = -1)</b><br/>
</p>
<p>Erases a range of characters from the string, starting at position <em>pos</em> and counting <em>count</em> characters.</p>
<p><b>int findFirst(const string &amp;in str, uint start = 0) const</b><br/>
</p>
<p>Find the first occurrence of the value <em>str</em> in the string, starting at <em>start</em>. If no occurrence is found a negative value will be returned.</p>
<p><b>int findLast(const string &amp;in str, int start = -1) const</b><br/>
</p>
<p>Find the last occurrence of the value <em>str</em> in the string. If <em>start</em> is informed the search will begin at that position, i.e. any potential occurrence after that position will not be searched. If no occurrence is found a negative value will be returned.</p>
<p><b>int findFirstOf(const string &amp;in chars, int start = 0) const</b><br/>
 <b>int findFirstNotOf(const string &amp;in chars, int start = 0) const</b><br/>
 <b>int findLastOf(const string &amp;in chars, int start = -1) const</b><br/>
 <b>int findLastNotOf(const string &amp;in chars, int start = -1) const</b><br/>
</p>
<p>The first variant finds the first character in the string that matches on of the characters in <em>chars</em>, starting at <em>start</em>. If no occurrence is found a negative value will be returned.</p>
<p>The second variant finds the first character that doesn't match any of those in <em>chars</em>. The third and last variant are the same except they start the search from the end of the string.</p>
<dl class="section note"><dt>Note</dt><dd>These functions work on the individual bytes in the strings. They do not attempt to understand encoded characters, e.g. UTF-8 encoded characters that can take up to 4 bytes.</dd></dl>
<p><b>array&lt;string&gt;@ split(const string &amp;in delimiter) const</b><br/>
</p>
<p>Splits the string in smaller strings where the delimiter is found.</p>
<h2><a class="anchor" id="doc_datatypes_strings_addon_funcs"></a>
Functions</h2>
<p><b>string join(const array&lt;string&gt; &amp;in arr, const string &amp;in delimiter)</b><br/>
</p>
<p>Concatenates the strings in the array into a large string, separated by the delimiter.</p>
<p><b>int64 parseInt(const string &amp;in str, uint base = 10, uint &amp;out byteCount = 0)</b><br/>
 <b>uint64 parseUInt(const string &amp;in str, uint base = 10, uint &amp;out byteCount = 0)</b><br/>
</p>
<p>Parses the string for an integer value. The <em>base</em> can be 10 or 16 to support decimal numbers or hexadecimal numbers. If <em>byteCount</em> is provided it will be set to the number of bytes that were considered as part of the integer value.</p>
<p><b>double parseFloat(const string &amp;in, uint &amp;out byteCount = 0)</b><br/>
</p>
<p>Parses the string for a floating point value. If <em>byteCount</em> is provided it will be set to the number of bytes that were considered as part of the value.</p>
<p><b>string formatInt(int64 val, const string &amp;in options = '', uint width = 0)</b><br/>
 <b>string formatUInt(uint64 val, const string &amp;in options = '', uint width = 0)</b><br/>
 <b>string formatFloat(double val, const string &amp;in options = '', uint width = 0, uint precision = 0)</b><br/>
</p>
<p>The format functions takes a string that defines how the number should be formatted. The string is a combination of the following characters:</p>
<ul>
<li>l = left justify</li>
<li>0 = pad with zeroes</li>
<li>+ = always include the sign, even if positive</li>
<li>space = add a space in case of positive number</li>
<li>h = hexadecimal integer small letters (not valid for formatFloat)</li>
<li>H = hexadecimal integer capital letters (not valid for formatFloat)</li>
<li>e = exponent character with small e (only valid for formatFloat)</li>
<li>E = exponent character with capital E (only valid for formatFloat)</li>
</ul>
<p>Examples:</p>
<pre>
  // Left justify number in string with 10 characters
  string justified = formatInt(number, 'l', 10);</pre><pre>  // Create hexadecimal representation with capital letters, right justified
  string hex = formatInt(number, 'H', 10);</pre><pre>  // Right justified, padded with zeroes and two digits after decimal separator
  string num = formatFloat(number, '0', 8, 2);
</pre> </div></div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Sun Dec 18 2016 12:35:30 for AngelScript by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.3.1 </li>
  </ul>
</div>
</body>
</html>
